<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>管理后台</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.4 -->
    <link href="/public/static/admin/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="/public/static/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/public/static/admin/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="/public/static/admin/css/animate.css" rel="stylesheet">
    <link href="/public/static/admin/css/ratuo.css" rel="stylesheet">
    <link href="/public/static/admin/css/style.css?v=4.0.0" rel="stylesheet">
    <!-- jQuery 2.1.4 -->
    <script src="/public/static/admin/js/jquery.min.js?v=2.1.4"></script>
    <script src="/public/static/admin/js/bootstrap.min.js?v=3.3.5"></script>
    <!-- <script src="/public/static/admin/js/myFormValidate.js"></script> -->
    <script src="/public/static/admin/js/common.js"></script>
    <script src="/public/static/admin/js/myAjax.js"></script>
    <script src="/public/static/admin/js/plugins/layer/layer.min.js"></script>
    <script src="/public/static/admin/js/jquery.validate.js"></script>
    <!-- iCheck -->
    <link href="/public/static/admin/css/plugins/iCheck/custom.css" rel="stylesheet">
    <script src="/public/static/admin/js/plugins/iCheck/icheck.min.js"></script>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">


    <div class="row">
        <div class="col-xs-12">
            <nav class="navbar navbar-default" style="display:none;">
                <div class="collapse navbar-collapse">
                    <div class="navbar-form pull-right margin">
                          &lt;!&ndash;{if $order['order_status'] < 2}
                             <a href="{:url('order/edit_order',array('order_id'=>$order['order_id']))}" data-toggle="tooltip" title="" class="btn btn-primary" data-original-title="编辑">修改订单</a>
                          {/if}&ndash;&gt;
                          &lt;!&ndash;{if ($split == 1) and ($order['order_status'] < 2)}
                             <a href="{:url('order/split_order',array('order_id'=>$order['order_id']))}" data-toggle="tooltip" title="" class="btn btn-primary" data-original-title="编辑">拆分订单</a>
                          {/if}&ndash;&gt;

                   </div>
                </div>
            </nav>
   
            <!--新订单列表 基本信息-->
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>基本信息</h5>
                    <div style="float: right;margin-top:-10px;display: none;">
                        <a href="javascript:history.go(-1)" data-toggle="tooltip" title="" class="btn btn-primary" data-original-title="返回"><i class="fa fa-reply"></i>返回</a>
                    </div>
                </div>
                <div class="ibox-content">
                    <table class="table table-bordered">
                        <tbody>
                            <tr>
                                <th>订单 ID</th>
                                <th>订单号</th>
                                <th>会员</th>
                                <th>订单状态</th>
                                <th>下单时间</th>
                                <th>支付状态</th>
                                <th>支付时间</th>
                                <th>支付方式</th>
                            </tr>
                            <tr>
                                <td>{$orderInfo.order_id}</td>
                                <td>{$orderInfo.order_sn}</td>
                                <td>{$orderInfo.consignee} ({$orderInfo.mobile})</td>
                                <td id="order-status">{$orderInfo[zhuangtai]}</td>
                                <td>{$orderInfo.add_time|date='Y-m-d H:i'}</td>
                                <td>{if $orderInfo.pay_status == 0}未支付{else/}已支付{/if}</td>
                            	<td>{if $orderInfo.pay_time <> 0}
                                        {$orderInfo.pay_time|date='Y-m-d H:i:s'}
                                    {else/}
                                        N
                                    {/if}
                                </td>             
                                <td id="pay-type">
                                    {$orderInfo.pay_name|default='其他方式'}
                                </td>
                            </tr>

                        </tbody>
                    </table>
                </div>
            </div>
            <!--新订单列表 收货人信息-->
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>收货信息</h5>
                </div>
                <div class="ibox-content">
                    <table class="table table-bordered">
                        <tbody>
                            <tr>
            					<th>发货状态</th>
                                <th>收货人</th>
                                <th>地址</th>
                                <th>发货信息</th>
                                <th>发货时间</th>
                            </tr>
                            <tr>
                                <td>{if $orderInfo.shipping_status == 0}未发货{elseif $orderInfo.shipping_status == 1/}已发货{elseif $orderInfo.shipping_status == 2/}已收货{/if}</td>
                                <td>{$orderInfo.consignee} ({$orderInfo.mobile})</td>
                                <td>{$orderInfo.address}</td>
                                <td>{if $orderInfo.shipping_status <> 0}{$orderInfo.shipping_name} - {$orderInfo.shipping_code}{/if}</td>
                                <td>{if $orderInfo['shipping_time']}{$orderInfo.shipping_time|date='Y-m-d H:i:s'}{/if}</td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
            <!--新订单列表 商品信息-->
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>商品信息</h5>
                </div>
                <div class="ibox-content">
                    <table class="table table-bordered">
                        <thead>
                        <tr>
                            <th>商品</th>
                            <th>数量</th>
                            <th>单品价格</th>
                            <th>单品小计</th>
                        </tr>
                        </thead>
                        <tbody>
                        {volist name="orderGoods" id="good"}
                            <tr>
                                <td>{$good.goods_name}</td>
                                <td>{$good.goods_num}</td>
                                <td>{$good.goods_price}</td>
                                <td>{$good.total_price}</td>
                            </tr>
                        {/volist}

                        <tr>
                            <td colspan="3" class="text-right">商品合计:</td>
                            <td>{$orderInfo.goods_price}</td>
                        </tr>
                        <tr>
                            <td colspan="3" class="text-right">订单总价:</td>
                            <td>{$orderInfo.total_amount}</td>
                        </tr>
                        </tbody>
                    </table>

                </div>
            </div>

            <!-- 发货操作 -->
            {if $orderInfo['order_status'] == 0 and $orderInfo['pay_status'] == 1 and $orderInfo['shipping_status'] == 0}
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>发货操作</h5>
                </div>
                <div class="ibox-content">
                    <form action="" id="shipping_status">
                    <table class="table table-bordered">
                        <tbody>
                        <tr>
                            <div class="row">
                                <th class="text-right col-sm-2"><p class="margin">快递物流</p></th>
                                <td colspan="3">
                                    <input type="text" class="form-control" name="shipping_name" placeholder="请填写物流名称">
                                </td>
                            </div>
                        </tr>
                        <tr>
                            <div class="row">
                                <th class="text-right col-sm-2"><p class="margin">快递单号</p></th>
                                <td colspan="3">
                                    <input type="text" class="form-control" name="shipping_code" placeholder="请填写快递单号">
                                    <input type="hidden" name="id" value="{$orderInfo.order_id}">
                                </td>
                            </div>
                        </tr>
                        <tr>
                            <div class="row">
                                <th class="text-right col-sm-2"><p class="margin"></p></th>
                                <td colspan="3">
                                    <div class="input-group">
                                        <a class="btn btn-primary margin" href="javascript:;" onclick="ChangeStatus('确定发货吗？','shipping_status','{$orderInfo.fahuo_url}')">发货</a>
                                    </div>
                                </td>
                            </div>
                        </tr>
                        </tbody>
                    </table>
                    </form>
                </div>
            </div>
            {/if}
            <!--新订单列表 操作信息-->
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>操作信息</h5>
                </div>
                <div class="ibox-content">
                    <table class="table table-bordered">
                        <tbody>
                        <tr>
                            <div class="row">
                                <th class="text-right col-sm-2"><p class="margin">操作备注</p></th>
                                <td colspan="3">
                                    <form id="order-action">
                                        <textarea name="note" placeholder="请输入操作备注" rows="3" class="form-control">{$orderInfo.admin_note}</textarea>
                                        <input type="hidden" name="id" value="{$orderInfo.order_id}">
                                    </form>
                                </td>
                            </div>
                        </tr>
                        <tr>
                            <div class="row">
                                <th class="text-right col-sm-2"><p class="margin">当前可执行操作</p></th>
                                <td colspan="3">
                                    <div class="input-group">
                                        {if $orderInfo['order_status'] == 0}
                                            {if $orderInfo['pay_status'] == 0}
                                                <a class="btn btn-primary margin" href="javascript:;" onclick="ChangeStatus('确定修改支付状态吗？','order-action','{$orderInfo.zhifu_url}')">支付</a>
                                            {else/}
                                                <a class="btn btn-primary margin" href="javascript:;" onclick="ChangeStatus('确定修改订单状态吗？','order-action','{$orderInfo.end_url}')">标记为完成</a>
                                            {/if}
                                        {/if}
                                    </div>
                                </td>
                            </div>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>

            <!--新订单列表 操作记录信息-->
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>操作记录</h5>
                </div>
                <div class="ibox-content">
                    <table class="table table-bordered">
                        <thead>
                        <tr>
                            <th>操作者</th>
                            <th>操作时间</th>
                            <th>备注</th>
                            <th>描述</th>
                        </tr>
                        </thead>
                        <tbody>
                        {volist name="action_log" id="log"}
                            <tr>
                                <td>{$log.user_name}</td>
                                <td>{$log.add_time|date='Y-m-d H:i:s'}</td>
                                <td>{$log.note}</td>
                                <td>{$log.text}</td>
                            </tr>
                        {/volist}
                        </tbody>
                    </table>
                </div>
              </div>
            </div>
	    </div>
    </div> 

</div>
</body>
<script>
    function ChangeStatus(name,formId,url) {
        top.layer.confirm(name,{
            icon : 3,
            btn:['确定','取消'],
        } , function(){
            var formData = $('#'+formId).serialize();
            $.ajax({
                url : url,
                type : "post",
                data : formData,
                dataType : "json",
                success:function(data){
                    if (data.status == 1) { 
                        var index = top.layer.getFrameIndex(window.name);
                        top.layer.msg(data.message,{icon:1,time:3000});
                        parent.$("#content-main").find('iframe:visible')[0].contentWindow.$("#handle_url").val(location.href);
                        top.layer.close(index);
                    } else {
                        top.layer.msg(data.message,{icon:2});
                        // $(obj).parent().parent().remove();
                    }
                }
            });
        } , function(){
            layer.close(); //再执行关闭 
        })
    }
    /*function pay_cancel(obj){
        var url =  $(obj).attr('data-url')+'/'+Math.random();
        layer.open({
            type: 2,
            title: '退款操作',
            shadeClose: true,
            shade: 0.8,
            area: ['45%', '50%'],
            content: url, 
        });
    }*/
    //取消付款
    function pay_callback(s){
    	if(s==1){
    		layer.msg('操作成功', {icon: 1});
    		layer.closeAll('iframe');
    	}else{
    		layer.msg('操作失败', {icon: 3});
    		layer.closeAll('iframe');
    	}
    }

    // 弹出退换货商品
    function selectGoods2(order_id){
    	var url = "/index.php?m=Admin&c=Order&a=get_order_goods&order_id="+order_id;
    	layer.open({
    		type: 2,
    		title: '选择商品',
    		shadeClose: true,
    		shade: 0.8,
    		area: ['60%', '60%'],
    		content: url, 
    	});
    }    
    // 申请退换货
    function call_back(order_id,goods_id){
    	var url = "/index.php?m=Admin&c=Order&a=add_return_goods&order_id="+order_id+"&goods_id="+goods_id;	
    	location.href = url;
    }
</script>
</html>